<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 50px;
            border: 1px solid pink;
            text-align: center;
            line-height: 50px;
        }
    </style>
</head>
<body>
   <div class="box">黄忠
   </div> 
   <button>点击随机点名</button>
   <script>
    const button = document.querySelector('button')
    const box =  document.querySelector('.box')
    function getRandom(min,max){
        return Math.floor( Math.random()*(min - max+1)+ min)
    }
    let arr = ['小杨','黄忠','蝴蝶','白起','貂蝉','鲁班']
    button.addEventListener('click',function(){
        let randomNum = getRandom(0 , arr, length -1)
        console.log(randomNum)
        box.innerHTML
    })
   </script>
</body>
</html>